
const { ipcRenderer } = require('electron');

export const articleReview = async (title, articleContent, callback) => {
    const prefix = "我正在学"+window.location.lectureValue+window.location.langValue+"，请你改进我的作文。文章题目是"+title+"，这是我的作文: ";
    const replyKey = 'articleReview-reply';
    const params = {
      'replyKey': replyKey,
      'model':'llama3',
      'prompt': prefix +articleContent,
      'stream':false
    };

    ipcRenderer.send('request-model', params);

    ipcRenderer.once(replyKey, function (event, data) {
      callback(data.response)
    })
}

export const advise2Chinese = (adviseContent, callback) => {
  const prompt = window.location.langValue+"老师批改我写的"+window.location.lectureValue+"作文时提出了一些建议，请你帮我稍微翻译为易懂中文，引号内的内容和涉及作文具体句子的内容都要保持"+window.location.langValue+"原文。内容如下："+adviseContent;
  const replyKey = 'advise2Chinese-reply';
  const params = {
    'replyKey': replyKey,
    'model':'qwen2.5-coder',
    'prompt': prompt,
    'stream':false};

  ipcRenderer.send('request-model', params);

  ipcRenderer.once(replyKey, function (event, data) {
    callback(data.response)
  })
}

export const translateSentence = (sentence, callback) => {
  const prompt = "请帮我在这段话翻译为"+window.location.langValue+":"+sentence;
  const replyKey = 'translateSentence-reply';
  const params = {
    'replyKey': replyKey,
    'model':'llama3',
    'prompt': prompt,
    'stream':false};

  ipcRenderer.send('request-model', params);

  ipcRenderer.once(replyKey, function (event, data) {
    callback(data.response)
  })
}

export const questionAnswer = (question, callback) => {
  const prompt = "我在学" + window.location.langValue+", 但是有个语法想不明白，如下："+question;
  const replyKey = 'questionAnswer-reply';
  const params = {
    'replyKey': replyKey,
    'model':'llama3',
    'prompt': prompt,
    'stream':false};

  ipcRenderer.send('request-model', params);

  ipcRenderer.once(replyKey, function (event, data) {
    callback(data.response)
  })
}